/**
 * Notes: 模板消息管理
 * Ver : CCMiniCloud Framework 2.0.1 ALL RIGHTS RESERVED BY cclinux@qq.com
 * Date: 2022-01-22 10:20:00 
 */

const BaseAdminService = require('./base_admin_service.js');
const cloudBase = require('../../../framework/cloud/cloud_base.js');
const timeUtil = require('../../../framework/utils/time_util.js');

class AdminTempService extends BaseAdminService {

    /** 更新订阅消息码 */
    async updateTemp(tempId) {
        let cloud = cloudBase.getCloud();
        let result = await cloud.openapi.subscribeMessage.getCategory();
        console.log(result);
        return result;
    }

    /** 发送订阅消息 */
    async sendTemp(tempId, openId, data) {
        let cloud = cloudBase.getCloud();
        let result = await cloud.openapi.subscribeMessage.send({
            touser: openId,
            templateId: tempId,
            data
        });
        console.log(result);
        return result;
    }

    /** 获取订阅消息列表 */
    async getTempList() {
        let cloud = cloudBase.getCloud();
        let result = await cloud.openapi.subscribeMessage.getPubTemplateTitleList({
            limit: 100
        });
        console.log(result);
        return result;
    }
}

module.exports = AdminTempService;